package com.lzy.crm.wechat.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lzy.crm.base.util.StringUtil;
import com.lzy.crm.domain.PpSystemStatusInfo;
import com.lzy.crm.service.PpSystemStatusInfoService;


/**
 * 游戏字典服务器
 * @author Administrator
 *
 */
@Controller
@RequestMapping("/gm")
public class GmPpSystemStatusInfoController {
	
	@Resource
	private PpSystemStatusInfoService  pSystemStatusInfoService;
	
	/**
	 * 游戏版本校验
	 * @param request
	 * @param model
	 * @return
	 */
	@RequestMapping(path="/update",method=RequestMethod.GET,produces="text/html;charset=UTF-8")
	@ResponseBody
	public String loginGame(HttpServletRequest request,ModelMap model) {
		String version = request.getParameter("version");
		String type = request.getParameter("type");
		
		PpSystemStatusInfo pSystemStatusInfo =pSystemStatusInfoService.getById("download_address");
		
		String retVersion = "";
		// IOS
		if(StringUtil.equals(type, "1")){
			// 如果版本号 相同
			if(StringUtil.equals(version, pSystemStatusInfo.getStatusString())){
				retVersion = "0|0|0";
			}else{
				retVersion = "1|0|0";
			}
		}
		
		// 安卓
		if(StringUtil.equals(type, "2")){
			// 如果版本号 相同
			if(StringUtil.equals(version, pSystemStatusInfo.getStatusString())){
				retVersion = "0|0|0";
			}else{
				retVersion = "1|0|0";
			}
		}
		//上线注释掉
		retVersion = "0|0|0";
		return retVersion;
	}
	
	

}
